
package com.rt.schedulenew.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.rt.schedulebase.dto.ExamSmsNoticeDto;
import com.rt.schedulebase.entity.ExamSmsNotice;
import com.rt.schedulebase.mapper.ExamSmsNoticeMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.rt.schedulenew.api.IExamSmsNoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//@Service("ExamSmsNoticeService")
@Service
public class ExamSmsNoticeServiceImpl extends ServiceImpl<ExamSmsNoticeMapper, ExamSmsNotice> implements IExamSmsNoticeService {
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    @Override
    public int insert(ExamSmsNotice examSmsNotice) {
        return baseMapper.insert(examSmsNotice);
    }
    @Override
    public boolean insertSelective(ExamSmsNotice examSmsNotice) {
        return retBool(baseMapper.insert(examSmsNotice));
    }
    @Override
    public boolean deleteByPrimaryKey(String key) {
        return retBool(baseMapper.deleteById(key));
    }
    @Override
    public boolean updateByPrimaryKeySelective(ExamSmsNotice examSmsNotice) {
        return retBool(baseMapper.updateById(examSmsNotice));
    }
    @Override
    public ExamSmsNotice selectByPrimaryKey(String key) {
        return baseMapper.selectById(key);
    }
    @Override
    public List<ExamSmsNotice> getList(ExamSmsNoticeDto dto) {
        QueryWrapper<ExamSmsNotice> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<>();
        map.put("APPLY_NO", dto.getApplyNo());
        map.put("PHONE_NUMBER", dto.getPhoneNumber());
        map.put("SEND_STATUS", dto.getSendStatus());
        map.put("SEND_COUNT", dto.getSendCount());
        map.put("CREATE_DATE", dto.getCreateDate());
        qw.allEq(map, false);
        List<ExamSmsNotice> list = baseMapper.selectList(qw);
        return list;
    }
    @Override
    public List<ExamSmsNotice> getListAll() {
        return baseMapper.selectList(null);
    }
    @Override
    public boolean delete(ExamSmsNotice examSmsNotice) {
        UpdateWrapper<ExamSmsNotice> uw = new UpdateWrapper<>();
        Map<String, Object> map = new HashMap<>();
        map.put("SMS_NO", examSmsNotice.getExamNo());
        uw.allEq(map, false);
        return retBool(baseMapper.delete(uw));
    }
    @Override
    public boolean update(ExamSmsNotice examSmsNotice) {
        UpdateWrapper<ExamSmsNotice> uw = new UpdateWrapper<>();
        Map<String, Object> map = new HashMap<>();
        uw.allEq(map, false);
        return retBool(baseMapper.update(examSmsNotice, uw));
    }
    @Override
    public ExamSmsNotice getInfo(ExamSmsNoticeDto dto) {
        QueryWrapper<ExamSmsNotice> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("APPLY_NO", dto.getApplyNo());
        map.put("PHONE_NUMBER", dto.getPhoneNumber());
        map.put("SEND_STATUS", dto.getSendStatus());
        map.put("SEND_COUNT", dto.getSendCount());
        map.put("CREATE_DATE", dto.getCreateDate());
        map.put("SMS_NO", dto.getSmsNo());
        qw.allEq(map, false);
        return baseMapper.selectOne(qw);
    }
}
